FROM php:7.1-fpm

# apt-get安装依赖时并非静默安装，需要交互，所以无法正常通过，设置此变量后，可有效解决
ENV DEBIAN_FRONTEND noninteractive

# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 将本地源文件复制到镜像
COPY ./sources.list /etc/apt/sources.list

## Update Ubuntu
RUN apt-get update

## mcrypt
RUN apt-get install -y apt-utils libmcrypt-dev
RUN docker-php-ext-install mcrypt

## GD
RUN apt-get install -y libfreetype6-dev libjpeg-dev libpng-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) gd

## Intl
RUN apt-get install -y libicu-dev
RUN docker-php-ext-configure intl
RUN docker-php-ext-install -j$(nproc) intl

# pgsql, pdo_pgsql
RUN apt-get install -y --no-install-recommends libpq-dev
RUN docker-php-ext-install -j$(nproc) pgsql pdo_pgsql

# redis
RUN pecl install redis \
    && rm -rf /tmp/pear \
    && docker-php-ext-enable redis

# swoole
RUN pecl install swoole \
    && docker-php-ext-enable swoole

## General
RUN docker-php-ext-install bcmath zip pcntl opcache pdo_mysql mysqli mbstring

# 将本地php.ini复制到镜像中
ADD php.ini /usr/local/etc/php/php.ini